A video sequence is generally stored according to a specific frame structure. H.264 is used as an example, and a video frame structure of H.264 may be, for example, IPP . . . PP IPP . . . PPIPP . . . PP . . . , where an I frame (random access frame) is a frame that can be independently decoded, and a P frame (common frame) is a frame that cannot be independently decoded and decoding of the P frame needs to depend on an I frame before the P frame. When a video with such a frame structure is dragged to play or edited, an I frame corresponding to a target time point for dragging or editing needs to be found first.
Generally, in scenarios such as video surveillance and static observation and photography, a video background remains unchanged in a quite long time. Based on this characteristic, video encoding efficiency can be significantly improved using an optimized encoding technology. After the optimized encoding technology is used, a frame structure of a video sequence changes accordingly, including a background frame, a random access frame, and a common frame, where only the background frame can be independently decoded, and decoding of both the random access frame and a common frame needs to depend on the corresponding background frame. When a video with such a frame structure is dragged to play or edited, a random access frame corresponding to a target time point for dragging or editing may be found first. However, with only the random access frame, decoding cannot be performed, and all frames located before the random access frame need to be searched for in a traversal manner according to frame header data of the random access frame in order to determine a background frame on which decoding of the random access frame depends.
However, a traversal method is a searching method with extremely low efficiency, thereby severely reducing efficiency of decoding a video frame.